<%--
 *  File:   MonthPopWindow.jsp
 *  Desc:	expensetype pop for report page
 *
 *  Date		   Author		  
 *  2011-3-15	  JackYin		  
 *
 *  Copyright (C) 2000 - 2005 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%
  //init param
  String privilegeCode = "ALL";
  String strTableName = "v_monthsummary";
  String strModuleName = "COM";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc" %>
<html>
<head>
<title>OrgPopWindow</title>
<PageFlow:CheckPageFlow pageName="p_monthsummary"/>

<%
  	Vector  monthsresult = (Vector)pageContext.getAttribute("monthsresult");
  	if( monthsresult == null)
  	{
  		monthsresult = new Vector();
  	}
    int totalsize  =  monthsresult.size();
 %>
<%@ include file="/inc/CatchError.inc" %>
<%@ include file="/inc/SumDiv.inc" %>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>
<script language="JavaScript">
<%--  put your custom script here   --%>



function clickRow(obj,idx)
{
  var cform = document.cform;
  cform.id.value = eval('obj.all.id'+idx).value;
}

function page_done(){
   for(var i = 0; i <<%=totalsize%>; i++){  
    if(document.getElementById('userid'+i).checked){
      	if(isEmpty(document.cform.selectedvalue.value)){
        	document.cform.selectedvalue.value = document.getElementById('userid'+i).value;
      	}else{
      	    document.cform.selectedvalue.value = document.cform.selectedvalue.value + "," + document.getElementById('userid'+i).value;;
      	}  
      	if(isEmpty(document.cform.selectedvaluename.value)){
       		document.cform.selectedvaluename.value = document.getElementById('valuename'+i).value;
     	}else{
        	document.cform.selectedvaluename.value = document.cform.selectedvaluename.value + "," + document.getElementById('valuename'+i).value;;
      	}    
      }
   }
 parent.page_setMonth(document.cform.selectedvalue.value,document.cform.selectedvaluename.value);
 parent.hideMonth();
}


function page_close(){
	parent.hideMonth();
}

function clickCheckBox(obj){
	if(cform.numrows.value == 0){
		cform.selectedids.checked=obj.checked;
	}else if(cform.numrows.value >= 1){
		var j=0;
		for(var i=0;i<Number(cform.numrows.value);i++){
			var idchk=document.getElementById('userid'+j);
			if(idchk){
				idchk.checked=obj.checked;
			}
			j++;
		}
	}
}
function clearCheckFlag(obj){
	if(!obj.checked){
		cform.checkallbox.checked=false;
	}
}
</script>
</head>

<body>
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
<input type="hidden" name="pagename" value="p_monthsummary">
<input type="hidden" name="actionname">  
<input type="hidden" name="numrows" value="<%=totalsize%>">
<custom:hidden property="selectedvalue"/> 
<custom:hidden property="selectedvaluename"/> 
    <table width="100%" cellspacing="0" border="0" cellpadding="0">
      <tr>
<%--  search criteria  --%>
      </tr>
    
      <tr>
        <td>
          <table width="100%" border="0" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <tr class="deepblue-left" >
		  <td width="40%">
			<%if(totalsize > 0){ %>
				<input  type="checkbox" name="checkallbox" class="checkbox"  onclick="clickCheckBox(this)">
			<%}else{ %>
				&nbsp;
			<%} %>
		  </td>
          <td width="60%" class="td_center"><%= label.getLabelName("L_Month") %></td>

        </tr>
		 <% //--------------------------------------  default value definition --%>
          	<%
            	int i = 0;
             	String strClassType = new String();
          	%>

          	<% //--------------------------------------  loop results --%>
		<logic:iterate id="onerow" collection="<%=monthsresult %>" indexId="idx">
           	<%
            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
           	
            	if(i%2 == 1)
            	{
              		strClassType = "td-listrom";
            	}else{
              		strClassType = "";
            	}
            	i++;
          	%>
          	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  class="none">
          		<td width="40%">
              		<input id="userid<%= idx %>" type="checkbox" name="userid" value="<%=JspHelper.filterNull( tempMap.get("value") )%>" class="checkbox" onclick="clearCheckFlag(this)">
            	</td>
            	<td width="60%" class="td_center">
            
            		<custom:write name="onerow" property="valuename"/>
            	</td>
            	
              		<custom:hidden name="onerow" property="valuename" colIndex="<%= idx %>" />
              		<custom:hidden name="onerow" property="value" colIndex="<%= idx %>" />
     		 </tr>
     	 </logic:iterate>

          </table>
          <table width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td class="td_left">
                <a onclick="page_done();"><custom:button type="1" label="L_Ok" imgsrc="add.gif" border="0" style="align:left;width:30"/></a>&nbsp;
              	<a onclick="page_close();"><custom:button type="1" label="L_Close" imgsrc="close.gif" border="0" style="width:30"/></a>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
</form>
</body>
</html>